Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • import delimited "C:\OneDrive\Final\`x'.csv working on Mac but not PC

    Dear all,
    I am trying to run code which looks like
    Code:
    foreach x in us_fdiflowsstock us_fdiflowsstock {
        import delimited "C:\OneDrive\Final \`x'.csv", clear
    which continues with me reshaping them and merging them into a main dataset.
    The datasets are for fdi flows and fdi stocks - both from the world bank so their contents look identical (beyond the fact that the data is different for flows/stocks).
    This code works on my Mac (after replacing file directory to be Mac-friendly of course) but on my PC it gives the following,
    Code:
     file C:\OneDrive\Final.csv not found
    Is there a way to fix this without getting rid of the loop?
    Thanks!

    P.S. I made a post somewhat like this yesterday - that was me making a typing error and then misremembering and thinking that I was coming across this issue.

  • #2
    Update: I guessed that Stata was somewhat like LaTeX in that backslashes changed it - so changed it to "import delimited "C:\OneDrive\Final\\`x'.csv"" which worked. Of course I did not have this issue on my Mac because the file directories use forward-slashes.
    Would it be possible for someone to explain to me what backslahes do - I can always use an opportunity to learn!

    Comment


    • #3
      Another update: in my first file each of the us_fdiflowsstock files had numbers after them which I deleted for brevity. I did not realise that this would make them identical. They are both different files, one containing FDI flows and the other FDI stocks.

      Comment


      • #4
        Regarding backslashes, read Cox (2008).

        Note that you can (and probably should) use forward slashes with Windows, too.


        Cox, N. J. 2008. Stata tip 65: Beware the backstabbing backslash. The Stata Journal,8(3): 446--447.

        Comment


        • #5
          Thank you for your helpful reply! I did not know that I could use forward slashes on Windows - I will be implementing that immediately.

          Comment

          Working...
          X